<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\searchs\PersonSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '人员管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="person-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('新增人员', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?
        $url = 'index.php?r=backend/person/assign';
    ?>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'name',
            'tel',
            'mobile',
            'email:email',
            [
                'class' => 'yii\grid\ActionColumn',
                'header'=>'操作','template' => '{assign} {view} {update} {delete}',
                'buttons' => [
                    'assign' => function ($url, $model, $key) {
                        if(!$model->is_assigned)
                            return  Html::a('<span class="glyphicon glyphicon-user"></span>', $url, ['title' => '分配账号'] ) ;
                    },
                ],
                'headerOptions' => ['width' => '180'],

            ],

        ],
    ]); ?>

</div>
